﻿using System;
using System.Collections.Generic;
using System.Text;
using NTL.DAL;

namespace NTL.BLL.Galleries
{
	public class Comment : BizObject
	{
		private long _galleryId;
		private long _imageId;
		private long _commentId;
		private DateTime _addedDate;
		private string _addedBy;
		private string _text;

		public long GalleryId { get { return _galleryId; } set { _galleryId = value; } }
		public long ImageId { get { return _imageId; } set { _imageId = value; } }
		public long CommentId { get { return _commentId; } set { _commentId = value; } }
		public DateTime AddedDate { get { return _addedDate; } set { _addedDate = value; } }
		public string AddedBy { get { return _addedBy; } set { _addedBy = value; } }
		public string Text { get { return _text; } set { _text = value; } }

		public Comment(long galleryId, long imageId, long commentId, DateTime addedDate, string addedBy, string text)
		{
			_galleryId = galleryId;
			_imageId = imageId;
			_commentId = commentId;
			_addedDate = addedDate;
			_addedBy = addedBy;
			_text = text;
		}

		/***********
		 * PRIVATE *
		 ***********/
		private static Comment GetFromDetails(CommentDetails record)
		{
			if (record == null) return null;
			return new Comment(record.GalleryId, record.ImageId, record.CommentId,
				record.AddedDate, record.AddedBy, record.Text);
		}
		private static List<Comment> GetListFromDetailsList(List<CommentDetails> recordset)
		{
			List<Comment> comments = new List<Comment>();
			foreach (CommentDetails record in recordset)
				comments.Add(GetFromDetails(record));
			return comments;
		}
	}
}
